import React from 'react';
import Loadable from 'react-loadable';

const Loading = ({isLoading, pastDelay, error}) => {
  if (isLoading && pastDelay) {
    return <p>Loading...</p>;
  } else if (error && !isLoading) {
    return <p>Error!</p>;
  } else {
    return null;
  }
}

export default loader => {
  return Loadable({
    loader: loader,
    loading: Loading,
  });
}
